package com.app.controller 
{
	import org.puremvc.as3.interfaces.ICommand;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	import org.puremvc.as3.interfaces.INotification;
	
	import com.app.AppFacade;
	import com.app.view.AppMediator;
	
	import com.app.model.SystemTipsProxy;
	
	/**
	 * ...
	 * @author kevin
	 */
	public class NoticeCommand extends SimpleCommand implements ICommand
	{
		
		override public function execute(notification:INotification):void
		{
			var name:String = notification.getName();
			var params:* = notification.getBody();
			
			var callback:Function = null;
			if (params.length == 2) callback = params[1];

			switch(name)
			{
				case AppFacade.SERVER_NOTICE:
					sendNotification(AppMediator.NOTICE_RESPONSE, [{"msg": systemTipsP.serverTips["error_" + String(params[0])], "callback": callback}]);
					
					break;
					
				case AppFacade.CLIENT_NOTICE:
				
					sendNotification(AppMediator.NOTICE_RESPONSE, [{"msg": systemTipsP.clientTips[params[0]], "callback": callback}]);
					
					break;
			}
		}
		
		
		///////////////////////////////////////
		///// model 引用
		//////////////////////////////////////
		private function get systemTipsP():SystemTipsProxy
		{
			return facade.retrieveProxy(SystemTipsProxy.NAME) as SystemTipsProxy;
		}
		
	}

}